const app = getApp();
Page({
    data: {
        btnClick:false,
        wNumber: "",
        company: "顺丰",
        com:'sf',
        cont: "",
        arrIndex:0,
        express_corporation: [
            { com: "顺丰", no: "sf" },
            { com: "申通", no: "sto" },
            { com: "圆通", no: "yt" },
            { com: "韵达", no: "yd" },
            { com: "天天", no: "tt" },
            { com: "EMS", no: "ems" },
            { com: "中通", no: "zto" },
            { com: "汇通（百世快递）", no: "ht" },
            { com: "全峰", no: "qf" },
            { com: "德邦", no: "db" },
            { com: "自动匹配", no: "auto" },
            { com: "国通", no: "gt" },
            { com: "如风达", no: "rfd" },
            { com: "京东快递", no: "jd" },
            { com: "宅急送", no: "zjs" },
            { com: "EMS国际", no: "emsg" },
            { com: "Fedex国际", no: "fedex" },
            { com: "邮政国内（挂号信）", no: "yzgn" },
            { com: "UPS国际快递", no: "ups" },
            { com: "中铁快运", no: "ztky" },
            { com: "佳吉快运", no: "jiaji" },
            { com: "速尔快递", no: "suer" },
            { com: "信丰物流", no: "xfwl" },
            { com: "优速快递", no: "yousu" },
            { com: "中邮物流", no: "zhongyou" },
            { com: "天地华宇", no: "tdhy" },
            { com: "安信达快递", no: "axd" },
            { com: "快捷速递", no: "kuaijie" },
            { com: "AAE全球专递", no: "aae" },
            { com: "DHL", no: "dhl" },
            { com: "DPEX国际快递", no: "dpex" },
            { com: "D速物流", no: "ds" },
            { com: "FEDEX国内快递", no: "fedexcn" },
            { com: "OCS", no: "ocs" },
            { com: "TNT", no: "tnt" },
            { com: "东方快递", no: "coe" },
            { com: "传喜物流", no: "cxwl" },
            { com: "城市100", no: "cs" },
            { com: "城市之星物流", no: "cszx" },
            { com: "安捷快递", no: "aj" },
            { com: "百福东方", no: "bfdf" },
            { com: "程光快递", no: "chengguang" },
            { com: "递四方快递", no: "dsf" },
            { com: "长通物流", no: "ctwl" },
            { com: "飞豹快递", no: "feibao" },
            { com: "马来西亚（大包EMS）", no: "malaysiaems" },
            { com: "安能快递", no: "ane66" },
            { com: "中通快运", no: "ztoky" },
            { com: "远成物流", no: "ycgky" },
            { com: "远成快运", no: "ycky" },
            { com: "邮政快递", no: "youzheng" },
            { com: "百世快运", no: "bsky" },
            { com: "苏宁快递", no: "suning" },
            { com: "安能物流", no: "anneng" },
            { com: "九曳", no: "jiuye" },
            { com: "品骏快递", no: "pjbest" },
            { com: "壹米滴答", no: "ymdd" },
            { com: "极兔快递", no: "jitu" },
            { com: "佐川急便", no: "zuochuan" },
            { com: "同城快寄", no: "shpost" },
            { com: "众邮快递", no: "zhongyouex" }
        ],
    },
    onLoad(query) {
        let param = JSON.parse(query.param)
        if (param) {
            this.setData(param);
        }
    },


    
    bindObjPickerChange(e) {
        console.log('picker发送选择改变，携带值为', e.detail.value);
        this.setData({
            arrIndex: e.detail.value,
            company: this.data.express_corporation[e.detail.value].com,
            com: this.data.express_corporation[e.detail.value].no
        });
    },
    
    // 输入订单号
    setInfo(e) {
        console.log(e)
        this.setData({
            [e.target.dataset.name]: e.detail.value.replace(/\s+/, ''),
        });
    },
    onClear(e){
        this.setData({
            wNumber: '',
        });
    },


    // 上传
    onSubmit() {
      let data = {
          company: this.data.com,
          number: this.data.wNumber,
          oid: this.data.id
      }
      console.log(data)
      app.order.giveBack(data)
      .then(res=>{
          console.log(res)
          my.showToast({
              content: res.msg,
          });
          if (res.code == 200) {
              this.setData({
                  btnClick:true
              })
              setTimeout(()=>{
                my.navigateBack();
              },1000)
          }
      })
    },

    // 复制
    clipboardOrderId() {
        app.clipboard({
            text: "".concat(
                this.data.city,
                this.data.district,
                this.data.province,
                this.data.city, this.data.district, this.data.province)
        });
    }

});
